<?php
/**
 *
 * @Author nikm $
 *
 * @Date 2012-04-14 $
 */

if(!defined('FROM_INDEX')) exit('Invalid request');

require ROOT_PATH.'servlet/module/master.mod.php';

class moduleObj extends masterObj
{
	function __construct($request)
	{
		parent::__construct($request);
				
		$this->excute();
	}
	
	private function excute()
	{		
		switch($this->act)
		{
			case 'list':
				$this->getList();
				break;
			default:
				$this->message('g_04', STATUS_E);
				break;
		}
		
		$this->showResponse();
	}
	
	private function getList()
	{
		//DBFunction::getInstance()->setDebug();
		
		$type_list = array('business'=>'bu', 'hostel'=>'ho', 'scenic'=>'sc', 'shop'=>'sh');
		$type = isset($this->request['type']) ? $this->request['type'] : '';
		$this->request['type'] = isset($type_list[$type]) ? $type_list[$type] : 'bu';
		
		$this->request['is_auth'] = 'true';
				
		$result = get_credit_list($this->request);
		
		if(!check_array($result['result'])) $this->message('cl_01', STATUS_F);
		
		foreach($result['result'] as &$temp)
		{
			$temp['image'] = ($temp['image'] != '') ? BASE_URL.$temp['image'] : '';
			$temp['image_s'] = str_replace('_o.', '_s.', $temp['image']);
		}
		
		$this->response['status'] = STATUS_S;
		$this->response['count'] = (string)count($result['result']);
		$this->response['list'] = $result['result'];
	}
}